import time
from multiprocessing import Process, Queue


def is_prime(num):
    if num <= 1:
        return False
    for tem in range(2, num // 2 + 1):
        if num % tem == 0:
            return False
    return True


def process_1(be, fi):
    prime = []
    for x in range(be, fi):
        if is_prime(x):
            prime.append(i)
    q.put(sum(prime))


begin = time.time()
q = Queue()
for data in [(1, 20001), (20001, 40001), (40001, 60001), (60001, 80001), (80001, 100001)]:
    p = Process(target=process_1, args=data)
    p.start()
res = 0
for i in range(5):
    res += q.get()
print(res)
final = time.time()
total = final-begin
print("Total time:", total)
